<template>
    <div id="temp">
        <div class="stuInfo">
            <div class="tit">
                <span>课程详情</span>
                <span class="icon" @click="openCourseEdit"></span>
                <!-- 修改课程详情 -->
                <div class="modification">
                    <el-dialog title="" :visible.sync="dialogFormVisible_kcxq">
                        <el-form :model="form" :rules="rules" ref="form" :label-width="formLabelWidth">
                            <el-row>
                                <el-col :span="8">
                                    <div>
                                        <el-form-item label="课程编码" prop="code">
                                            <el-input v-model="form.code"></el-input>
                                        </el-form-item>
                                        <el-form-item label="课程地点" prop="place">
                                            <el-select style="width:100%" v-model="form.place" placeholder="请选择">
                                                <el-option label="课程" value="课程"></el-option>
                                                <el-option label="研讨会" value="研讨会"></el-option>
                                                <el-option label="办公室培训" value="办公室培训"></el-option>
                                                <el-option label="船上培训" value="船上培训"></el-option>
                                                <el-option label="异地培训" value="异地培训"></el-option>
                                            </el-select>
                                        </el-form-item>
                                        <el-form-item label="课程天数" prop="days">
                                            <el-input v-model="form.days"></el-input>
                                        </el-form-item>
                                        <el-form-item label="最小开班人数" prop="minnum">
                                            <el-input v-model="form.minnum"></el-input>
                                        </el-form-item>
                                        <el-form-item label="模拟器评估" prop="simulator">
                                            <el-radio-group v-model="form.simulator">
                                                <el-radio label="是">是</el-radio>
                                                <el-radio label="否">否</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="课前考试评估" prop="pre_test">
                                            <el-radio-group v-model="form.pre_test">
                                                <el-radio label="是">是</el-radio>
                                                <el-radio label="否">否</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="课后考试评估" prop="after_test">
                                            <el-radio-group v-model="form.after_test">
                                                <el-radio label="是">是</el-radio>
                                                <el-radio label="否">否</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="课程授权方" prop="authorization">
                                            <el-select style="width:100%" v-model="form.authorization" clearable filterable>
                                                <el-option v-for="item in authorizationList" :key="item.id"
                                                           :label="item.name" :value="item.id"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </div>
                                </el-col>
                                <el-col :span="8">
                                    <div>
                                        <el-form-item label="课程名称" prop="name">
                                            <el-input v-model="form.name"></el-input>
                                        </el-form-item>
                                        <el-form-item label="课程类型" prop="type">
                                            <el-select style="width:100%" v-model="form.type" clearable filterable>
                                                <el-option v-for="item in courseList" :key="item.id" :label="item.name"
                                                           :value="item.id"></el-option>
                                            </el-select>
                                        </el-form-item>
                                        <el-form-item label="证书有效期" prop="certificate_time">
                                            <el-input v-model="form.certificate_time" placeholder="单位(月)"></el-input>
                                        </el-form-item>
                                        <el-form-item label="最大开班人数" prop="maxnum">
                                            <el-input v-model="form.maxnum"></el-input>
                                        </el-form-item>
                                        <el-form-item label="反馈" prop="feedback">
                                            <el-radio-group v-model="form.feedback">
                                                <el-radio label="是">是</el-radio>
                                                <el-radio label="否">否</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="课前测评合格分" prop="pre_test_score">
                                            <el-input v-model="form.pre_test_score" :disabled="form.pre_test == '否'"></el-input>
                                        </el-form-item>
                                        <el-form-item label="课后测评合格分" prop="after_test_score">
                                            <el-input v-model="form.after_test_score" :disabled="form.after_test == '否'"></el-input>
                                        </el-form-item>
                                        <el-form-item label="积分兑换比例" prop="integral">
                                            <el-input v-model="form.integral"></el-input>
                                        </el-form-item>
                                    </div>
                                </el-col>
                                <el-col :span="8">
                                    <div>
                                        <el-form-item label="课程分级" prop="rank">
                                            <el-input v-model="form.rank"></el-input>
                                        </el-form-item>
                                        <el-form-item label="收费标准" prop="standardfee">
                                            <el-input v-model="form.standardfee"></el-input>
                                        </el-form-item>
                                        <el-form-item label="IMO示范课程" prop="imo">
                                            <el-radio-group v-model="form.imo">
                                                <el-radio label="是">是</el-radio>
                                                <el-radio label="否">否</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="标准开班人数" prop="standardnum">
                                            <el-input v-model="form.standardnum"></el-input>
                                        </el-form-item>
                                        <el-form-item label="课程开发日期" prop="startdate">
                                            <el-date-picker v-model="form.startdate" type="date" placeholder="选择日期">
                                            </el-date-picker>
                                        </el-form-item>
                                        <el-form-item label="新课程到期" prop="enddate">
                                            <el-date-picker v-model="form.enddate" type="date" placeholder="选择日期">
                                            </el-date-picker>
                                        </el-form-item>
                                        <el-form-item label="课程成本" prop="cost">
                                            <el-input v-model="form.cost"></el-input>
                                        </el-form-item>
                                    </div>
                                </el-col>
                            </el-row>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="editCourseSub">提 交</el-button>
                        </div>
                    </el-dialog>
                </div>
            </div>
            <el-row>
                <el-col :span="7">
                    <div>
                        <el-col :span="11">
                            <span class="left">课程编码：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.code}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">课程地点：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.place}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">课程天数：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.days}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">最小开班人数：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.minnum}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">是否使用模拟器：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.simulator}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">课前考试评估：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.pre_test}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">课后考试评估：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.after_test}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left bd-bt">课程成本：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.cost}}</span>
                        </el-col>
                    </div>

                </el-col>
                <el-col :span="7">
                    <div>
                        <el-col :span="11">
                            <span class="left">课程名称：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.name}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">课程类型：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.type_name}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">证书有效期：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.certificate_time}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">最大开班人数：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.maxnum}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">反馈：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.feedback}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">课前测评合格分：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.pre_test_score}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left bd-bt">课后测评合格分：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.after_test_score}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left bd-bt">积分兑换比例：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.integral}}</span>
                        </el-col>
                    </div>
                </el-col>
                <el-col :span="7">
                    <div>
                        <el-col :span="11">
                            <span class="left">课程分级：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.rank}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">收费标准：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.standardfee}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">IMO示范课程：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.imo}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">标准开班人数：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.standardnum}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left">课程开发日期：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.startdate}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left bd-bt">新课程到期：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.enddate}}</span>
                        </el-col>
                    </div>
                    <div>
                        <el-col :span="11">
                            <span class="left bd-bt">课程授权方：</span>
                        </el-col>
                        <el-col :span="13">
                            <span class="right">{{info.authorization_name}}</span>
                        </el-col>
                    </div>
                </el-col>
                <el-col :span="3">
                    <div class="headPic">
                        <el-upload class="avatar-uploader" :action="action" :show-file-list="false"
                                   :on-success="handleUploadSuccess"
                                   :on-progress="handleUpload" :data="{id: id}">
                            <img v-if="info.img" :src="info.img" class="avatar">
                            <img v-else src="../../img/default.png" class="avatar">
                        </el-upload>
                    </div>
                </el-col>
            </el-row>
        </div>
        <div class="record">
            <el-tabs type="border-card" @tab-click="handleChange">
                <el-tab-pane label="课程介绍">
                    <el-form style="margin-top:20px;">
                        <el-form-item label="课程简介" label-width="80px">
                            <el-input type="textarea" v-model="courseDesc" :rows="5"></el-input>
                        </el-form-item>
                    </el-form>
                    <div class="editorBox">
                        <span>课程介绍</span>
                        <div id="editorElem"></div>
                    </div>
                    <div style="text-align:center;margin-top:20px">
                        <el-button type="primary" @click="subEditor">提交</el-button>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="章代码" name="CourseChapter">
                    <table class="tab-table">
                        <thead>
                            <tr>
                                <th>
                                    <span class="icon add" @click="openAdd('Chapter')"></span>
                                </th>
                                <!-- <th>序号</th> -->
                                <th>章代码</th>
                                <th>章名称</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="(item,index) in list" :key="item.id">
                                <td>
                                    <span class="icon edit" @click="edit('Chapter', item.id)"></span>
                                    <span class="icon del" @click="del('Chapter', item.id)"></span>
                                </td>
                                <!-- <td>{{index + 1}}</td> -->
                                <td>{{item.code}}</td>
                                <td>{{item.name}}</td>
                            </tr>
                        </tbody>
                    </table>
                    <el-dialog title="" :visible.sync="dialogFormChapter" size="tiny">
                        <el-form :model="Chapter" :rules="ChapterRules" ref="Chapter" label-width="80px">
                            <el-form-item label="章代码" prop="code">
                                <el-input v-model="Chapter.code"></el-input>                                
                            </el-form-item>
                            <el-form-item label="章名称" prop="name" size="small">
                                <el-input v-model="Chapter.name"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="submit('Chapter')">提 交</el-button>
                        </div>
                    </el-dialog>
                </el-tab-pane>
                <el-tab-pane label="教学计划">
                    <el-tabs v-model="activeName1" @tab-click="handleClick">
                        <el-tab-pane label="课程框架" name="courseFrame">
                            <el-row style="padding:0 150px">
                                <el-form :model="frame" ref="frameForm">
                                    <el-col :span="12">
                                        <div style="padding-right:50px">
                                            <el-form-item label="范围" label-width="80px">
                                                <el-input type="textarea" v-model="frame.fanwei"></el-input>
                                            </el-form-item>
                                            <el-form-item label="参考STCW" label-width="80px">
                                                <el-input type="textarea" v-model="frame.cankao"></el-input>
                                            </el-form-item>
                                            <el-form-item label="师资要求" label-width="80px">
                                                <el-input type="textarea" v-model="frame.shizi"></el-input>
                                            </el-form-item>
                                            <el-form-item label="教学目的" label-width="80px">
                                                <el-input type="textarea" v-model="frame.mudi"></el-input>
                                            </el-form-item>
                                        </div>
                                    </el-col>
                                    <el-col :span="12">
                                        <div style="padding-left:50px">
                                            <el-form-item label="教学目标" label-width="80px">
                                                <el-input type="textarea" v-model="frame.mubiao"></el-input>
                                            </el-form-item>
                                            <el-form-item label="入学标准" label-width="80px">
                                                <el-input type="textarea" v-model="frame.biaozhun"></el-input>
                                            </el-form-item>
                                            <el-form-item label="教学设备与设施" label-width="80px">
                                                <el-input type="textarea" v-model="frame.shebei"></el-input>
                                            </el-form-item>
                                            <el-form-item label="教材" label-width="80px">
                                                <el-input type="textarea" v-model="frame.jiaocai"></el-input>
                                            </el-form-item>
                                        </div>
                                    </el-col>
                                </el-form>

                            </el-row>
                            <div class="proBtn">
                                <el-button type="primary" @click="frameSubmit">更新课程信息</el-button>
                            </div>
                        </el-tab-pane>
                        <el-tab-pane label="教学大纲" name="courseSyllabus">
                            <table class="tab-table">
                                <thead>
                                <tr>
                                    <th>
                                        <span class="icon add" @click="openAdd('Syllabus')"></span>
                                    </th>
                                    <th>序号</th>
                                    <th>课程内容</th>
                                    <th>授课学时</th>
                                    <th>活动学时</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr v-for="(item, index) in list" :key="item.id">
                                    <td>
                                        <span class="icon edit" @click="edit('Syllabus',item.id)"></span>
                                        <span class="icon del" @click="del('Syllabus', item.id)"></span>
                                    </td>
                                    <td>{{index + 1}}</td>
                                    <td>{{item.content}}</td>
                                    <td>{{item.lecture}}</td>
                                    <td>{{item.practice}}</td>
                                </tr>
                                </tbody>
                            </table>
                            <!-- 教学大纲表单弹框 -->
                            <el-dialog title="" :visible.sync="dialogFormSyllabus" size="tiny">
                                <el-form :model="Syllabus" :rules="SyllabusRules" ref="Syllabus"
                                         :label-width="formLabelWidth">
                                    <el-form-item label="课程内容" prop="content">
                                        <el-input type="textarea" :rows="3" v-model="Syllabus.content"
                                                  placeholder="请输入内容"></el-input>
                                    </el-form-item>
                                    <el-form-item label="课程学时" prop="lecture">
                                        <el-input v-model="Syllabus.lecture" size="small"></el-input>
                                    </el-form-item>
                                    <el-form-item label="活动学时" prop="practice">
                                        <el-input v-model="Syllabus.practice" size="small"></el-input>
                                    </el-form-item>
                                </el-form>
                                <div slot="footer" class="dialog-footer">
                                    <el-button type="primary" @click="submit('Syllabus')">提 交</el-button>
                                </div>
                            </el-dialog>
                        </el-tab-pane>
                        <el-tab-pane label="教学计划" name="coursePlan">
                            <table class="tab-table">
                                <thead>
                                <tr>
                                    <th>
                                        <!--<span class="icon add" @click="dialogFormVisible_jxjh=true"></span>-->
                                    </th>
                                    <th>内容</th>
                                    <th>知识、理解和熟练</th>
                                    <th>IMO参考资料</th>
                                    <th>培训资料</th>
                                    <th>辅助资料</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr v-for="(item, index) in list" :key="item.id">
                                    <td>
                                        <span class="icon edit" @click="edit('Plan', item.id)"></span>
                                        <!--<span class="icon del" @click="open2"></span>-->
                                    </td>
                                    <td>{{index + 1}}</td>
                                    <td>{{item.knowledge}}</td>
                                    <td>{{item.imo}}</td>
                                    <td>{{item.peixun}}</td>
                                    <td>{{item.fuzhu}}</td>
                                </tr>
                                </tbody>
                            </table>
                            <!-- 教学计划表单弹框 -->
                            <el-dialog title="" :visible.sync="dialogFormPlan" size="tiny">
                                <el-form :model="Plan" ref="Plan" label-width="130px">
                                    <el-form-item label="内容">
                                        <el-input v-model="Plan.content" :disabled="true" size="small"></el-input>
                                    </el-form-item>
                                    <el-form-item label="知识、理解和熟练" prop="knowledge">
                                        <el-input v-model="Plan.knowledge" size="small"></el-input>
                                    </el-form-item>
                                    <el-form-item label="IMO参考资料" prop="imo">
                                        <el-input v-model="Plan.imo" size="small"></el-input>
                                    </el-form-item>
                                    <el-form-item label="培训资料" prop="peixun">
                                        <el-input v-model="Plan.peixun" size="small"></el-input>
                                    </el-form-item>
                                    <el-form-item label="辅助资料" prop="fuzhu">
                                        <el-input v-model="Plan.fuzhu" size="small"></el-input>
                                    </el-form-item>
                                </el-form>
                                <div slot="footer" class="dialog-footer">
                                    <el-button type="primary" @click="submit('Plan')">提 交</el-button>
                                </div>
                            </el-dialog>
                        </el-tab-pane>
                    </el-tabs>
                </el-tab-pane>
                <el-tab-pane label="证书" name="certificate">
                    <!--<div class="uploadCredential">
                        <span class="fl">证书模板：</span>
                        <el-upload action="https://jsonplaceholder.typicode.com/posts/" list-type="picture-card"
                                   :on-success="handlePictureCardSuccess" :on-preview="handlePictureCardPreview">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog v-model="dialogVisible" size="tiny">
                            <img width="100%" :src="dialogImageUrl" alt="">
                        </el-dialog>
                    </div>
                    <div class="btn">
                        <el-button type="primary" v-show="!disabled || isSure">确定</el-button>
                    </div>-->
                    <table class="tab-table">
                        <thead>
                        <tr>
                            <th width="15%"></th>
                            <th>文件名</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>
                                <el-upload :action="acrion2" :on-preview="handlePictureCardPreview"
                                           :show-file-list="false"
                                           :on-success="handlePictureCardSuccess" :data="{id:this.id}">
                                    <span class="icon edit"></span>
                                </el-upload>
                            </td>
                            <td>{{certificate.certificate_name}}</td>
                        </tr>
                        </tbody>
                    </table>
                </el-tab-pane>
                <el-tab-pane label="培训师" name="courseTrainer">
                    <!-- 培训师表单弹框 -->
                    <el-dialog title="" :visible.sync="dialogFormTrainer" size="tiny">
                        <el-form :model="Trainer" :rules="TrainerRules" ref="Trainer" label-width="80px">
                            <el-form-item label="姓名" prop="staffid">
                                <el-select style="width:100%" v-model="Trainer.staffid" clearable filterable size="small">
                                    <el-option v-for="item in staffList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="优先级" prop="rank">
                                <el-input v-model="Trainer.rank" size="small"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="submit('Trainer')">提 交</el-button>
                        </div>
                    </el-dialog>
                    <el-dialog title="" :visible.sync="dialogFormOperator" size="tiny">
                        <el-form :model="Operator" :rules="TrainerRules" ref="Operator" label-width="80px">
                            <el-form-item label="姓名" prop="staffid">
                                <el-select style="width:100%" v-model="Operator.staffid" clearable filterable size="small">
                                    <el-option v-for="item in staffList" :key="item.id" :label="item.name"
                                               :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="优先级" prop="rank">
                                <el-input v-model="Operator.rank" size="small"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="submit('Operator')">提 交</el-button>
                        </div>
                    </el-dialog>
                    <el-tabs v-model="activeName2" @tab-click="handleClick">
                        <el-tab-pane label="主讲培训师" name="courseTrainer">
                            <table class="tab-table">
                                <thead>
                                <tr>
                                    <th>
                                        <span class="icon add" @click="openAdd('Trainer')"></span>
                                    </th>
                                    <th>序号</th>
                                    <th>姓名</th>
                                    <th>
                                        <span>优先级</span>&nbsp;&nbsp;&nbsp;
                                        <el-button type="primary" size="mini" @click="sort">升序</el-button>
                                        <el-button type="primary" size="mini" @click="rsort">降序</el-button>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr v-for="(item,index) in list" :key="item.id">
                                    <td>
                                        <span class="icon edit" @click="edit('Trainer', item.id)"></span>
                                        <span class="icon del" @click="del('Trainer', item.id)"></span>
                                    </td>
                                    <td>{{index + 1}}</td>
                                    <td>{{item.name}}</td>
                                    <td>{{item.rank}}</td>
                                </tr>
                                </tbody>
                            </table>
                        </el-tab-pane>
                        <el-tab-pane label="模拟器操作人员" name="courseOperator">
                            <table class="tab-table">
                                <thead>
                                <tr>
                                    <th>
                                        <span class="icon add" @click="openAdd('Operator')"></span>
                                    </th>
                                    <th>序号</th>
                                    <th>姓名</th>
                                    <th>
                                        <span>优先级</span>&nbsp;&nbsp;&nbsp;
                                        <el-button type="primary" size="mini" @click="sort">升序</el-button>
                                        <el-button type="primary" size="mini" @click="rsort">降序</el-button>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr v-for="(item,index) in list" :key="item.id">
                                    <td>
                                        <span class="icon edit" @click="edit('Operator', item.id)"></span>
                                        <span class="icon del" @click="del('Operator', item.id)"></span>
                                    </td>
                                    <td>{{index + 1}}</td>
                                    <td>{{item.name}}</td>
                                    <td>{{item.rank}}</td>
                                </tr>
                                </tbody>
                            </table>
                        </el-tab-pane>
                    </el-tabs>
                </el-tab-pane>
                <el-tab-pane label="教室" name="courseClassroom">
                    <!-- 教室表单弹框 -->
                    <el-dialog title="" :visible.sync="dialogFormClassroom" size="tiny">
                        <el-form :model="Classroom" :rules="ClassroomRules" ref="Classroom" label-width="80px">
                            <el-form-item label="教室" prop="classroomid">
                                <el-select style="width:100%" v-model="Classroom.classroomid" clearable filterable size="small">
                                    <el-option v-for="item in classroomList" :key="item.id" :label="item.name"
                                               :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="优先级" prop="rank" >
                                <el-input v-model="Classroom.rank" size="small"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="submit('Classroom')">提 交</el-button>
                        </div>
                    </el-dialog>
                    <el-dialog title="" :visible.sync="dialogFormSimulator" size="tiny">
                        <el-form :model="Simulator" :rules="SimulatorRules" ref="Simulator" label-width="80px">
                            <el-form-item label="模拟器" prop="simulatorid">
                                <el-select style="width:100%" v-model="Simulator.simulatorid" clearable filterable size="small">
                                    <el-option v-for="item in simulatorList" :key="item.id" :label="item.asset_name"
                                               :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="优先级" prop="rank" >
                                <el-input v-model="Simulator.rank" size="small"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="submit('Simulator')">提 交</el-button>
                        </div>
                    </el-dialog>
                    <el-tabs v-model="activeName3" @tab-click="handleClick">
                        <el-tab-pane label="教室" name="courseClassroom">
                            <table class="tab-table">
                                <thead>
                                    <tr>
                                        <th>
                                            <span class="icon add" @click="openAdd('Classroom')"></span>
                                        </th>
                                        <th>序号</th>
                                        <th>教室编号</th>
                                        <th>教室名称</th>
                                        <th>
                                            <span>优先级</span>&nbsp;&nbsp;&nbsp;
                                            <el-button type="primary" size="mini" @click="sort">升序</el-button>
                                            <el-button type="primary" size="mini" @click="rsort">降序</el-button>
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr v-for="(item,index) in list" :key="item.id">
                                        <td>
                                            <span class="icon edit" @click="edit('Classroom', item.id)"></span>
                                            <span class="icon del" @click="del('Classroom', item.id)"></span>
                                        </td>
                                        <td>{{index + 1}}</td>
                                        <td>{{item.number}}</td>
                                        <td>{{item.name}}</td>
                                        <td>{{item.rank}}</td>
                                    </tr>
                                </tbody>
                            </table>
                        </el-tab-pane>
                        <el-tab-pane label="模拟器" name="courseSimulator">
                            <table class="tab-table">
                                <thead>
                                <tr>
                                    <th>
                                        <span class="icon add" @click="openAdd('Simulator')"></span>
                                    </th>
                                    <th>序号</th>
                                    <th>编号</th>
                                    <th>模拟器名称</th>
                                    <th>
                                        <span>优先级</span>&nbsp;&nbsp;&nbsp;
                                        <el-button type="primary" size="mini" @click="sort">升序</el-button>
                                        <el-button type="primary" size="mini" @click="rsort">降序</el-button>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr v-for="(item,index) in list" :key="item.id">
                                    <td>
                                        <span class="icon edit" @click="edit('Simulator', item.id)"></span>
                                        <span class="icon del" @click="del('Simulator', item.id)"></span>
                                    </td>
                                    <td>{{index + 1}}</td>
                                    <td>{{item.asset_num}}</td>
                                    <td>{{item.asset_name}}</td>
                                    <td>{{item.rank}}</td>
                                </tr>
                                </tbody>
                            </table>
                        </el-tab-pane>
                    </el-tabs>
                </el-tab-pane>
                <el-tab-pane label="文件" name="courseFile">
                    <table class="tab-table">
                        <thead>
                        <tr>
                            <th>
                                <span class="icon add" @click="openAddFile"></span>
                            </th>
                            <th>序号</th>
                            <th>文件名</th>
                            <th>备注</th>
                            
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="(item, index) in list" :key="item.id">
                            <td>
                                <!--<span class="icon edit" @click="edit('File', item.id)"></span>-->
                                <span class="icon del" @click="del('File', item.id)"></span>
                            </td>
                            <td>{{index + 1}}</td>
                            <td>{{item.name}}</td>
                            <td>{{item.note}}</td>
                            
                        </tr>
                        </tbody>
                    </table>
                    <!-- 文件表单弹框 -->
                    <el-dialog title="" :visible.sync="dialogFormFile" size="tiny">
                        <el-form :model="File" ref="File" label-width="80px">
                            <el-form-item label="上传文件" prop="name">
                                <el-upload class="upload-demo" ref="upload" :action="fileAction"
                                           :on-change="fileUploadChange"
                                           :file-list="fileList" :auto-upload="false" :on-success="fileUploadSuccess"
                                           :on-remove="fileRemove" :data="uploadData">
                                    <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                </el-upload>
                            </el-form-item>
                            <el-form-item label="备注" prop="note">
                                <el-input type="textarea" :rows="5" v-model="File.note"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="submitFile" :disabled="subDisabled">提 交</el-button>
                        </div>
                    </el-dialog>
                </el-tab-pane>
                <el-tab-pane label="命题规则" name="coursePreTest">
                    <el-tabs v-model="activeName4" @tab-click="handleClickTest">
                        <el-tab-pane label="课前测评" name="coursePreTest">
                            <el-row>
                                <el-col :span="11">
                                    <div class="score">
                                        <table class="question-table">
                                            <thead>
                                            <tr>
                                                <th>试题类型</th>
                                                <th>题数</th>
                                                <th>分值</th>
                                                <th>合计</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr>
                                                <td>四选一</td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.choice.number">
                                                </td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.choice.score">
                                                </td>
                                                <td>{{questionNumList.choice.number * questionNumList.choice.score}}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>对错题</td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.TF.number">
                                                </td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.TF.score">
                                                </td>
                                                <td>{{questionNumList.TF.number * questionNumList.TF.score}}</td>
                                            </tr>
                                            <tr>
                                                <td>问答题</td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.essay.number">
                                                </td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.essay.score">
                                                </td>
                                                <td>{{questionNumList.essay.number * questionNumList.essay.score}}</td>
                                            </tr>
                                            
                                            <tr>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td>
                                                    <span>总分：</span>
                                                    <span ref="totalPoints">{{questionNumList.choice.number * questionNumList.choice.score + questionNumList.TF.number * questionNumList.TF.score + questionNumList.essay.number * questionNumList.essay.score}}</span>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </el-col>
                                <el-col :span="2">
                                    <div style="height:50px">
                                    </div>
                                </el-col>
                                <el-col :span="11">
                                    <div class="questions">
                                        <div class="difficulty">
                                            <span>试卷难度：</span>
                                            <input type="text" placeholder="请输入" v-model="difficulty">
                                        </div>
                                        <el-tabs v-model="questionTypes" type="card">
                                            <el-tab-pane label="四选一" name="choice">
                                                <table class="question-table">
                                                    <thead>
                                                    <tr>
                                                        <th>
                                                            <span class="icon add" @click="addQuestion"></span>
                                                        </th>
                                                        <th>语言代码</th>
                                                        <th>章代码</th>
                                                        <th>节代码</th>
                                                        <th>题目数</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr v-for="(item,index) in questionList.choice">
                                                        <td>
                                                            <span class="icon del" @click="openQues(index)"></span>
                                                        </td>
                                                        <td>
                                                            <select v-model="item.language">
                                                                <option value="" disabled selected>请选择</option>
                                                                <option value="E">E</option>
                                                                <option value="C">C</option>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.chapter">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.section">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.quesNum">
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </el-tab-pane>
                                            <el-tab-pane label="对错题" name="TF">
                                                <table class="question-table">
                                                    <thead>
                                                    <tr>
                                                        <th>
                                                            <span class="icon add" @click="addQuestion"></span>
                                                        </th>
                                                        <th>语言代码</th>
                                                        <th>章代码</th>
                                                        <th>节代码</th>
                                                        <th>题目数</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr v-for="(item,index) in questionList.TF">
                                                        <td>
                                                            <span class="icon del" @click="openQues(index)"></span>
                                                        </td>
                                                        <td>
                                                            <select v-model="item.language">
                                                                <option value="" disabled selected>请选择</option>
                                                                <option value="E">E</option>
                                                                <option value="C">C</option>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.chapter">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.section">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.quesNum">
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </el-tab-pane>
                                            <el-tab-pane label="问答题" name="essay">
                                                <table class="question-table">
                                                    <thead>
                                                    <tr>
                                                        <th>
                                                            <span class="icon add" @click="addQuestion"></span>
                                                        </th>
                                                        <th>语言代码</th>
                                                        <th>章代码</th>
                                                        <th>节代码</th>
                                                        <th>题目数</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr v-for="(item,index) in questionList.essay">
                                                        <td>
                                                            <span class="icon del" @click="openQues(index)"></span>
                                                        </td>
                                                        <td>
                                                            <select v-model="item.language">
                                                                <option value="" disabled selected>请选择</option>
                                                                <option value="E">E</option>
                                                                <option value="C">C</option>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.chapter">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.section">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.quesNum">
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </el-tab-pane>
                                            
                                        </el-tabs>
                                    </div>
                                </el-col>
                            </el-row>
                            <div class="submitBtn">
                                <el-button type="primary" @click="subPropositionForm('Pre')">提交</el-button>
                            </div>
                        </el-tab-pane>
                        <el-tab-pane label="课后测评" name="courseAfterTest">
                            <el-row>
                                <el-col :span="11">
                                    <div class="score">
                                        <table class="question-table">
                                            <thead>
                                            <tr>
                                                <th>试题类型</th>
                                                <th>题数</th>
                                                <th>分值</th>
                                                <th>合计</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr>
                                                <td>四选一</td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.choice.number">
                                                </td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.choice.score">
                                                </td>
                                                <td>{{questionNumList.choice.number * questionNumList.choice.score}}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>对错题</td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.TF.number">
                                                </td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.TF.score">
                                                </td>
                                                <td>{{questionNumList.TF.number * questionNumList.TF.score}}</td>
                                            </tr>
                                            <tr>
                                                <td>问答题</td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.essay.number">
                                                </td>
                                                <td>
                                                    <input type="text" placeholder="请输入"
                                                           v-model="questionNumList.essay.score">
                                                </td>
                                                <td>{{questionNumList.essay.number * questionNumList.essay.score}}</td>
                                            </tr>
                                           
                                            <tr>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td>
                                                    <span>总分：</span>
                                                    <span ref="totalPoints">{{questionNumList.choice.number * questionNumList.choice.score + questionNumList.TF.number * questionNumList.TF.score + questionNumList.essay.number * questionNumList.essay.score}}</span>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </el-col>
                                <el-col :span="2">
                                    <div style="height:50px">
                                    </div>
                                </el-col>
                                <el-col :span="11">
                                    <div class="questions">
                                        <div class="difficulty">
                                            <span>试卷难度：</span>
                                            <input type="text" placeholder="请输入" v-model="difficulty">
                                        </div>
                                        <el-tabs v-model="questionTypes" type="card">
                                            <el-tab-pane label="四选一" name="choice">
                                                <table class="question-table">
                                                    <thead>
                                                    <tr>
                                                        <th>
                                                            <span class="icon add" @click="addQuestion"></span>
                                                        </th>
                                                        <th>语言代码</th>
                                                        <th>章代码</th>
                                                        <th>节代码</th>
                                                        <th>题目数</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr v-for="(item,index) in questionList.choice">
                                                        <td>
                                                            <span class="icon del" @click="openQues(index)"></span>
                                                        </td>
                                                        <td>
                                                            <select v-model="item.language">
                                                                <option value="" disabled selected>请选择</option>
                                                                <option value="E">E</option>
                                                                <option value="C">C</option>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.chapter">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.section">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.quesNum">
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </el-tab-pane>
                                            <el-tab-pane label="对错题" name="TF">
                                                <table class="question-table">
                                                    <thead>
                                                    <tr>
                                                        <th>
                                                            <span class="icon add" @click="addQuestion"></span>
                                                        </th>
                                                        <th>语言代码</th>
                                                        <th>章代码</th>
                                                        <th>节代码</th>
                                                        <th>题目数</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr v-for="(item,index) in questionList.TF">
                                                        <td>
                                                            <span class="icon del" @click="openQues(index)"></span>
                                                        </td>
                                                        <td>
                                                            <select v-model="item.language">
                                                                <option value="" disabled selected>请选择</option>
                                                                <option value="E">E</option>
                                                                <option value="C">C</option>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.chapter">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.section">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.quesNum">
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </el-tab-pane>
                                            <el-tab-pane label="问答题" name="essay">
                                                <table class="question-table">
                                                    <thead>
                                                    <tr>
                                                        <th>
                                                            <span class="icon add" @click="addQuestion"></span>
                                                        </th>
                                                        <th>语言代码</th>
                                                        <th>章代码</th>
                                                        <th>节代码</th>
                                                        <th>题目数</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr v-for="(item,index) in questionList.essay">
                                                        <td>
                                                            <span class="icon del" @click="openQues(index)"></span>
                                                        </td>
                                                        <td>
                                                            <select v-model="item.language">
                                                                <option value="" disabled selected>请选择</option>
                                                                <option value="E">E</option>
                                                                <option value="C">C</option>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.chapter">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.section">
                                                        </td>
                                                        <td>
                                                            <input type="text" placeholder="请输入" v-model="item.quesNum">
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </el-tab-pane>
                                            
                                        </el-tabs>
                                    </div>
                                </el-col>
                            </el-row>
                            <div class="submitBtn">
                                <el-button type="primary" @click="subPropositionForm('After')">提交</el-button>
                            </div>
                        </el-tab-pane>
                    </el-tabs>
                </el-tab-pane>
                <el-tab-pane label="教学资料" name="courseDatum">
                    <table class="tab-table">
                        <thead>
                        <tr>
                            <th width="200px">
                                <span class="icon add" @click="openAdd('Datum')"></span>
                            </th>
                            <th width="200px">资料类型</th>
                            <th>名称</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="item in list" :key="item.id">
                            <td>
                                <span class="icon edit" @click="edit('Datum', item.id)"></span>
                                <span class="icon del" @click="del('Datum', item.id)"></span>
                            </td>
                            <td>{{item.type}}</td>
                            <td>{{item.name}}</td>
                        </tr>
                        </tbody>
                    </table>
                    <!-- 教学资料表单弹框 -->
                    <el-dialog title="" :visible.sync="dialogFormDatum" size="tiny">
                        <el-form :model="Datum" :rules="DatumRules" ref="Datum" :label-width="formLabelWidth">
                            <el-form-item label="资料类型" prop="type">
                                <el-input v-model="Datum.type" size="small"></el-input>
                            </el-form-item>
                            <el-form-item label="名称" prop="name">
                                <el-input v-model="Datum.name" size="small"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="submit('Datum')">提 交</el-button>
                        </div>
                    </el-dialog>
                </el-tab-pane>
                <el-tab-pane label="测评结果" name="Evaluation">
                    <div id="myChart" style="width:600px;height:400px;margin:20px auto"></div>
                </el-tab-pane>

            </el-tabs>
        </div>
    </div>
</template>
<script>
// import "../../assets/css/info.css";
import Editor from "wangeditor";

const Chapter = {
  id: "",
  code: "",
  name: ""
};
const Syllabus = {
  id: "",
  content: "",
  lecture: "",
  practice: ""
};
const Plan = {};
const Trainer = {
  id: "",
  staffid: "",
  rank: ""
};
const Operator = {
  id: "",
  staffid: "",
  rank: ""
};
const Classroom = {
  id: "",
  classroomid: "",
  rank: ""
};
const Simulator = {
  id: "",
  simulatorid: "",
  rank: ""
};
const File = {
  id: "",
  note: ""
};
const Datum = {
  id: "",
  type: "",
  name: ""
};

export default {
  data() {
    return {
      //图片上传地址
      imageUrl: "",
      activeName1: "courseFrame",
      activeName2: "courseTrainer",
      activeName3: "courseClassroom",
      activeName4: "first",
      dialogFormChapter: false,
      dialogFormVisible_kcxq: false,
      dialogFormSyllabus: false,
      dialogFormPlan: false,
      dialogFormTrainer: false,
      dialogFormOperator: false,
      dialogFormClassroom: false,
      dialogFormSimulator: false,
      dialogFormFile: false,
      dialogFormDatum: false,
      dialogFormVisible_question: false,
      dialogFormVisible_teaching: false,
      info: {},
      form: {
        id: "",
        code: "",
        name: "",
        rank: "",
        place: "",
        type: "",
        authorization: "",
        minnum: "",
        maxnum: "",
        standardnum: "",
        integral: "",
        feedback: "",
        pre_test: "",
        after_test: "",
        certificate_time: "",
        startdate: "",
        enddate: "",
        cost: "",
        days: "",
        standardfee: "",
        simulator: "",
        imo: "",
        pre_test_score: "",
        after_test_score: ""
      },
      rules: {
        code: [{ required: true, message: "请输入课程编码", trigger: "blur" }],
        name: [{ required: true, message: "请输入课程名称", trigger: "blur" }]
      },
      formLabelWidth: "120px",
      disabled: true,
      credentialName: "", //证书名称
      dialogImageUrl: "", //证书模板照片
      dialogVisible: false, //证书模板照片预览弹框
      isSure: false, //证书修改确定按钮
      fileList: [],
      questionNumList: {
        choice: { number: "", score: "" },
        TF: { number: "", score: "" },
        essay: { number: "", score: "" }
      },
      questionTypes: "choice",
      questionList: {
        //添加试题列表
        choice: [],
        TF: [],
        essay: []
      },
      difficulty: "", //试卷难度

      id: "",
      authorizationList: [],
      courseList: [],
      staffList: [],
      classroomList: [],
      simulatorList: [],
      action: PATH + "Train/courseEdit",
      acrion2: PATH + "Train/uploadCertificate",
      frame: {
        fanwei: "",
        cankao: "",
        shizi: "",
        mudi: "",
        mubiao: "",
        biaozhun: "",
        shebei: "",
        jiaocai: ""
      },
      list: [],
      Chapter: _g.cloneJson(Chapter),
      ChapterRules: {
        code: [
          { required: true, message: "请输入章代码", trigger: "blur" },
          { min: 2, max: 2, message: "章代码必须为2位数", trigger: "blur" }
        ],
        name: [{ required: true, message: "请输入章名称", trigger: "blur" }]
      },
      Syllabus: _g.cloneJson(Syllabus),
      SyllabusRules: {
        content: [{ required: true, message: "请输入课程内容", trigger: "blur" }]
      },
      Plan: {},
      Trainer: _g.cloneJson(Trainer),
      TrainerRules: {
        staffid: [
          {
            type: "number",
            required: true,
            message: "请选择培训师",
            trigger: "change"
          }
        ],
        rank: [{ required: true, message: "请填写培训师优先级", trigger: "blur" }]
      },
      Operator: _g.cloneJson(Operator),
      Classroom: _g.cloneJson(Classroom),
      ClassroomRules: {
        classroomid: [
          {
            type: "number",
            required: true,
            message: "请选择教室",
            trigger: "change"
          }
        ],
        rank: [{ required: true, message: "请填写教室优先级", trigger: "blur" }]
      },
      Simulator: _g.cloneJson(Simulator),
      SimulatorRules: {
        simulatorid: [
          {
            type: "number",
            required: true,
            message: "请选择模拟器",
            trigger: "change"
          }
        ],
        rank: [{ required: true, message: "请填写模拟器优先级", trigger: "blur" }]
      },
      File: _g.cloneJson(File),
      fileAction: PATH + "Train/courseFileEdit",
      subDisabled: true,
      uploadData: {
        id: "",
        note: "",
        courseid: ""
      },
      Datum: _g.cloneJson(Datum),
      DatumRules: {
        type: [{ required: true, message: "请填写资料类型", trigger: "blur" }],
        name: [{ required: true, message: "请填写资料名称", trigger: "blur" }]
      },
      courseDesc: "", //课程简介
      certificate: [],
      myChart: {},
      option: {
        title: {
          text: ""
        },
        // tooltip: {},
        toolbox: {
          show: true,
          right: 20,
          feature: {
            saveAsImage: {
              //保存图片
              show: true
            }
          }
        },
        legend: {
          data: []
        },
        radar: {
          name: {
            formatter: text => {
              text = text.replace(/\S{10}/g, function(match) {
                return match + "\n";
              });
              return text;
            },
            textStyle: {
              color: "#333"
            }
          },
          indicator: []
        },
        series: [
          {
            name: "测评结果",
            type: "radar",
            label: {
              normal: {
                show: true,
                formatter: function(params) {
                  return params.value;
                }
              }
            },
            data: []
          }
        ]
      }
    };
  },
  methods: {
    getUploadCertificate() {
      let data = { id: this.id };
      this.apiPost("Train/certificate", data).then(res => {
        this.certificate = res;
      });
    },
    //图片上传
    handleUploadSuccess(res) {
      let remind = res.error ? "error" : "success";
      _g.toastMsg(remind, res.msg);
      if (!res.error) {
        this.fetchData();
      }
    },
    handleUpload() {
      _g.openGlobalLoading();
    },
    handleClick(tab) {
      if (tab.name == "courseFrame" || !tab.name) {
        return;
      }
      let data = {
        id: this.id
      };
      this.apiPost("Train/" + tab.name, data).then(res => {
        this.list = res;
      });
    },
    handleChange(tab) {
      this.activeName1 = "courseFrame";
      this.activeName2 = "courseTrainer";
      this.activeName3 = "courseClassroom";
      this.activeName4 = "coursePreTest";
      if (!tab.name) {
        return;
      } else if (tab.name == "certificate") {
        this.getUploadCertificate();
      } else if (tab.name == "Evaluation") {
        this.myChart.showLoading("default", {
          color: "#0177BF"
        });
        let data1 = {
          id: this.id
        };
        this.apiPost("Train/courseTestResult", data1).then(res => {
          this.myChart.hideLoading();
          let legends = [];
          res.data.forEach(val => {
            legends.push(val.name);
          });
          this.myChart.setOption({
            legend: {
              data: legends
            },
            radar: {
              indicator: res.indocator
            },
            series: [
              {
                data: res.data
              }
            ]
          });
        });
      } else {
        let data = {
          id: this.id
        };
        this.apiPost("Train/" + tab.name, data).then(res => {
          if (tab.name == "coursePreTest") {
            this.questionList = res.questionList;
            this.questionNumList = res.questionNumList;
            this.difficulty = res.difficulty;
          } else {
            this.list = res;
          }
        });
      }
    },
    handleClickTest(tab) {
      let data = {
        id: this.id
      };
      this.apiPost("Train/" + tab.name, data).then(res => {
        this.questionList = res.questionList;
        this.questionNumList = res.questionNumList;
        this.difficulty = res.difficulty;
      });
    },
    //删除提示框
    open2() {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    //证书模板上传
    handlePictureCardSuccess() {
      this.isSure = true;
      this.getUploadCertificate();
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    //添加试题
    addQuestion() {
      if (!this.questionNumList[this.questionTypes].number) {
        this.$message.error("请先在左侧表格中输入题数");
      } else {
        let sum = 0;
        this.questionList[this.questionTypes].forEach(element => {
          sum += element.quesNum ? parseInt(element.quesNum) : 1;
        });
        let number = parseInt(this.questionNumList[this.questionTypes].number);
        if (
          this.questionList[this.questionTypes].length < number &&
          sum < number
        ) {
          this.questionList[this.questionTypes].push({
            language: "",
            chapter: "",
            section: "",
            quesNum: ""
          });
        } else {
          this.$message.error("已达到规定题数，不能再添加了");
        }
      }
    },
    // 删除试题
    openQues(index) {
      this.questionList[this.questionTypes].splice(index, 1);
      //      this.$confirm('确定要删除该试题吗？', '提示', {
      //        confirmButtonText: '确定',
      //        cancelButtonText: '取消',
      //        type: 'warning'
      //      }).then(() => {
      //
      //        this.$message({
      //          type: 'success',
      //          message: '删除成功!'
      //        });
      //      }).catch(() => {
      //        this.$message({
      //          type: 'info',
      //          message: '已取消删除'
      //        });
      //      });
    },
    // 提交命题规则
    subPropositionForm(name) {
      //      for (var k in this.questionNumList) {
      //        if (!this.questionNumList[k].number.trim()) {
      //          this.$message.error('题数不能为空');
      //          return;
      //        } else if (!this.questionNumList[k].score.trim()) {
      //          this.$message.error('分值不能为空');
      //          return;
      //        } else if (this.$refs.totalPoints.innerText != 100) {
      //          this.$message.error('总分必须等于100');
      //          return;
      //        }
      //      }
      if (this.$refs.totalPoints.innerText != 100) {
        this.$message.error("总分必须等于100");
        return;
      }
      let toastType = {
        choice: "四选一",
        TF: "对错题",
        essay: "问答题"
      };
      let arr = [];
      for (var key in this.questionList) {
        let sum = 0;
        arr = this.questionList[key];
        for (var i = 0; i < arr.length; i++) {
          sum += arr[i].quesNum ? parseInt(arr[i].quesNum) : 0;
          if (!arr[i].language) {
            this.$message.error('请选择"' + toastType[key] + '"题型的语言代码');
            return;
          } else if (!arr[i].chapter) {
            this.$message.error('请选择"' + toastType[key] + '"题型的章代码');
            return;
          } else if (!arr[i].section) {
            this.$message.error('请选择"' + toastType[key] + '"题型的节代码');
            return;
          } else if (!arr[i].quesNum.trim()) {
            this.$message.error('请选择"' + toastType[key] + '"题型的题目数');
            return;
          }
        }
        if (this.questionNumList[key].number != sum) {
          this.$message.error('"' + toastType[key] + '"题型的题目数与规定题数不一致');
          return;
        }
      }
      if (!this.difficulty.trim()) {
        this.$message.error("请输入试卷难度");
        return;
      }
      if (
        parseInt(this.difficulty.trim()) < 1 ||
        parseInt(this.difficulty.trim()) > 3
      ) {
        this.$message.error("试卷难度范围为1-3");
        return;
      }
      let data = {
        questionNumList: this.questionNumList,
        questionList: this.questionList,
        difficulty: this.difficulty,
        courseid: this.id
      };
      this.apiPost("Train/Course" + name + "TestEdit", data).then(res => {
        let remind = res.error ? "error" : "success";
        _g.toastMsg(remind, res.msg);
      });
    },

    fetchData() {
      let data = {
        id: this.id
      };
      this.apiPost("Train/courseDetail", data).then(res => {
        this.info = res;
        this.courseDesc = res.brief;
        this.editor.txt.html(res.intro);
        for (let k in this.frame) {
          this.frame[k] = res[k];
        }
      });
    },
    getCourseTypeList() {
      this.apiPost("System/courseTypeLists").then(res => {
        this.courseList = res;
      });
    },
    getCourseAuthorizationList() {
      this.apiPost("System/courseAuthorizationLists").then(res => {
        this.authorizationList = res;
      });
    },
    getStaffList() {
      this.apiPost("System/getStaffLists").then(res => {
        this.staffList = res;
      });
    },
    getClassroomList() {
      this.apiPost("System/getClassroomLists").then(res => {
        this.classroomList = res;
      });
    },
    getSimulatorList() {
      this.apiPost("System/getSimulatorLists").then(res => {
        this.simulatorList = res;
      });
    },
    openCourseEdit() {
      for (let k in this.form) {
        this.form[k] = this.info[k];
      }
      this.dialogFormVisible_kcxq = true;
    },
    editCourseSub() {
      this.$refs.form.validate(valid => {
        if (valid) {
					if(this.form.pre_test != '是'){
						this.form.pre_test_score = 0
					}
					if(this.form.after_test != '是'){
						this.form.after_test_score = 0
					}
          this.dialogFormVisible_kcxq = false;
          this.apiPost("Train/courseEdit", this.form).then(res => {
            let remind = res.error ? "error" : "success";
            _g.toastMsg(remind, res.msg);
            if (!res.error) {
              this.fetchData();
            } else {
              this.dialogFormVisible_kcxq = true;
            }
          });
        } else {
          return false;
        }
      });
    },
    frameSubmit() {
      let data = this.frame;
      data.id = this.id;
      this.apiPost("Train/courseFrame", data).then(res => {
        let remind = res.error ? "error" : "success";
        _g.toastMsg(remind, res.msg);
      });
    },
    openAdd(name) {
      this["dialogForm" + name] = true;
      setTimeout(() => {
        this.$refs[name].resetFields();
        this[name] = _g.cloneJson(eval(name));
      }, 0);
    },
    edit(name, id) {
      let data = {
        id: id
      };
      this.apiPost("Train/course" + name + "Detail", data).then(res => {
        this["dialogForm" + name] = true;
        setTimeout(() => {
          this.$refs[name].resetFields();
          this[name] = res;
        }, 0);
      });
    },
    del(name, id) {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let data = {
            id: id
          };
          this.apiPost("Train/course" + name + "Delete", data).then(res => {
            let remind = res.error ? "error" : "success";
            _g.toastMsg(remind, res.msg);
            if (!res.error) {
              let data = {
                id: this.id
              };
              this.apiPost("Train/course" + name, data).then(res => {
                this.list = res;
              });
            }
          });
        })
        .catch(() => {});
    },
    submit(name) {
      this.$refs[name].validate(valid => {
        if (valid) {
          this["dialogForm" + name] = false;
          let data = this[name];
          data.courseid = this.id;
          this.apiPost("Train/course" + name + "Edit", data).then(res => {
            let remind = res.error ? "error" : "success";
            _g.toastMsg(remind, res.msg);
            if (!res.error) {
              let data = {
                id: this.id
              };
              this.apiPost("Train/course" + name, data).then(res => {
                this.list = res;
              });
              this.$refs[name].resetFields();
              this[name] = _g.cloneJson(eval(name));
            } else {
              this["dialogForm" + name] = true;
            }
          });
        } else {
          return false;
        }
      });
    },
    sort() {
      this.list = this.list.sort(_g.sort("rank"));
    },
    rsort() {
      this.list = this.list.sort(_g.rsort("rank"));
    },
    fileUploadChange(file, fileList) {
      if (fileList.length > 1) {
        _g.toastMsg("warning", "每次限上传一个文件");
      }
      this.subDisabled = fileList.length == 1 ? false : true;
    },
    fileRemove(file, fileList) {
      this.subDisabled = fileList.length == 1 ? false : true;
    },
    fileUploadSuccess(res) {
      _g.closeGlobalLoading();
      let remind = res.error ? "error" : "success";
      _g.toastMsg(remind, res.msg);
      if (!res.error) {
        this.dialogFormFile = false;
        let data = {
          id: this.id
        };
        this.apiPost("Train/courseFile", data).then(res => {
          this.list = res;
        });
      }
    },
    fileUpload() {
      _g.openGlobalLoading();
    },
    submitFile() {
      this.uploadData.note = this.File.note;
      this.uploadData.courseid = this.id;
      setTimeout(() => {
        this.$refs.upload.submit();
      }, 0);
    },
    openAddFile() {
      this.dialogFormFile = true;
      setTimeout(() => {
        this.$refs.upload.clearFiles();
        this.$refs.File.resetFields();
        this.File = _g.cloneJson(File);
      }, 0);
    },
    subEditor() {
      let data = {
        id: this.id,
        brief: this.courseDesc,
        intro: this.editor.txt.html()
      };
      this.apiPost("Train/courseIntro", data).then(res => {});
    },
    drawChart() {
      this.myChart = this.$echarts.init(document.querySelector("#myChart"));
      this.myChart.setOption(this.option);
    }
  },

  created() {
    this.id = this.$route.params.id;
    this.fetchData();
    this.getCourseTypeList();
    this.getCourseAuthorizationList();
    this.getStaffList();
    this.getClassroomList();
    this.getSimulatorList();
  },
  mounted() {
    // 富文本编辑框
    this.editor = new Editor("#editorElem");
    this.editor.customConfig.uploadImgServer = PATH + "System/upload";
    this.editor.customConfig.uploadFileName = "file[]";
    this.editor.customConfig.customAlert = (info) => {
      console.log(info);
      //this.$message.error("图片上传失败！");
    };
    this.editor.create();
    this.drawChart();
  }
};
</script>
<style scoped>
.record .el-dialog__footer .dialog-footer {
  text-align: center;
}

.credential {
  padding-left: 30px;
  margin: 30px 0;
}

.credential input {
  padding: 0;
  border: 1px solid #bfcbd9;
  height: 28px;
  border-radius: 5px;
  margin-right: 20px;
}

.uploadCredential {
  padding-left: 30px;
}

.btn {
  padding-left: 30px;
  margin-top: 30px;
}

.filesType {
  padding-left: 30px;
  line-height: 50px;
}

.filesType select {
  height: 24px;
  min-width: 120px;
  padding-left: 5px;
}

.questions {
  position: relative;
}

.questions .difficulty {
  margin-bottom: 20px;
  font-size: 14px;
}

.questions .difficulty > input {
  height: 25px;
  border-radius: 5px;
  padding: 0 0 0 5px;
  border: 1px solid #bfcbd9;
  width: 100px;
}

.questions .add {
  background: url(../../img/add.gif) no-repeat;
  width: 16px;
  height: 16px;
}

.score input,
.questions table input,
.questions table select {
  width: 80px;
  border: 0;
  outline: none;
  background-color: rgba(0, 0, 0, 0);
  text-align: center;
  font-size: 12px;
  color: #666;
}

.submitBtn {
  text-align: center;
  margin-top: 30px;
}

.proBtn {
  text-align: center;
  margin-top: 30px;
}

.question-table {
  width: 100%;
  text-align: center;
  border-collapse: collapse;
}

.question-table thead th {
  height: 48px;
  background-color: #eff5f9;
  font-size: 14px;
}

.question-table tbody > tr td {
  height: 40px;
  font-size: 12px;
}

.question-table tbody > tr:nth-child(2n) {
  background-color: #eff5f9;
}

.editorBox > span {
  position: absolute;
  font-size: 14px;
  padding-left: 12px;
  color: #48576a;
  padding-top: 8px;
}

#editorElem {
  color: #333;
  padding-left: 80px;
  font-size: 14px;
}
</style>
